package com.pan.alg.niuke.link;

public class LinkDeleteDuplicates {
    /**
     *
     * @param head ListNode类
     * @return ListNode类
     */
    public ListNode deleteDuplicates (ListNode head) {
        if(head==null){
            return head;
        }
        // write code here
        ListNode pre = head;
        ListNode current = head.next;
        while(current!=null){
            if(current.val==pre.val){
                current=current.next;
                pre.next=current;
            }else{
                pre=current;
                current=current.next;

            }
        }
        return head;
    }
}
